<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>古诗填空小游戏</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            max-width: 600px;
            width: 100%;
            text-align: center;
        }

        h1 {
            color: #333;
            margin-bottom: 30px;
            font-size: 2.5em;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
        }

        .game-info {
            display: flex;
            justify-content: space-between;
            margin-bottom: 30px;
            font-size: 1.2em;
            color: #666;
        }

        .poem-container {
            background: #f8f9fa;
            border-radius: 15px;
            padding: 30px;
            margin-bottom: 30px;
            border: 2px solid #e9ecef;
        }

        .poem-title {
            font-size: 1.5em;
            color: #495057;
            margin-bottom: 20px;
            font-weight: bold;
        }

        .poem-author {
            color: #6c757d;
            margin-bottom: 25px;
            font-style: italic;
        }

        .poem-lines {
            font-size: 1.3em;
            line-height: 2;
            color: #212529;
        }

        .blank {
            display: inline-block;
            width: 80px;
            height: 40px;
            border: 2px dashed #007bff;
            border-radius: 8px;
            margin: 0 5px;
            text-align: center;
            font-size: 1.2em;
            background: #fff;
            color: #333;
        }

        .blank:focus {
            outline: none;
            border-color: #0056b3;
            box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
        }

        .submit-btn {
            background: linear-gradient(45deg, #007bff, #0056b3);
            color: white;
            border: none;
            padding: 15px 40px;
            border-radius: 25px;
            font-size: 1.2em;
            cursor: pointer;
            transition: all 0.3s ease;
            margin: 20px 10px;
        }

        .submit-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(0, 123, 255, 0.3);
        }

        .next-btn {
            background: linear-gradient(45deg, #28a745, #1e7e34);
        }

        .next-btn:hover {
            box-shadow: 0 10px 20px rgba(40, 167, 69, 0.3);
        }

        .result {
            margin: 20px 0;
            padding: 20px;
            border-radius: 10px;
            font-size: 1.1em;
        }

        .correct {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .incorrect {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        .full-poem {
            background: #e2f3ff;
            border: 1px solid #bee5eb;
            color: #0c5460;
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
            font-size: 1.1em;
            line-height: 1.8;
        }

        .score {
            font-size: 1.3em;
            color: #007bff;
            font-weight: bold;
        }

        @media (max-width: 768px) {
            .container {
                padding: 20px;
            }

            h1 {
                font-size: 2em;
            }

            .poem-lines {
                font-size: 1.1em;
            }

            .blank {
                width: 60px;
                height: 35px;
                font-size: 1em;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>🎯 古诗填空小游戏</h1>

        <div class="game-info">
            <span>第 <span id="currentQuestion">1</span> 题</span>
            <span>得分: <span id="score">0</span></span>
        </div>

        <div id="gameArea">
            <div class="poem-container">
                <div class="poem-title" id="poemTitle"></div>
                <div class="poem-author" id="poemAuthor"></div>
                <div class="poem-lines" id="poemLines"></div>
            </div>

            <button class="submit-btn" onclick="checkAnswer()">提交答案</button>
        </div>

        <div id="resultArea" style="display: none;"></div>
        <div id="fullPoemArea" style="display: none;"></div>
        <button id="nextBtn" class="submit-btn next-btn" onclick="nextQuestion()" style="display: none;">下一题</button>
    </div>

    <script>
        // 古诗数据库 - 80首适合3-8岁儿童的古诗
        const poems = [{
                title: "静夜思",
                author: "李白",
                content: "床前明月光，疑是地上霜。举头望明月，低头思故乡。",
                blanks: ["明月", "霜", "明月"]
            },
            {
                title: "春晓",
                author: "孟浩然",
                content: "春眠不觉晓，处处闻啼鸟。夜来风雨声，花落知多少。",
                blanks: ["晓", "鸟", "花"]
            },
            {
                title: "咏鹅",
                author: "骆宾王",
                content: "鹅鹅鹅，曲项向天歌。白毛浮绿水，红掌拨清波。",
                blanks: ["鹅", "歌", "绿"]
            },
            {
                title: "登鹳雀楼",
                author: "王之涣",
                content: "白日依山尽，黄河入海流。欲穷千里目，更上一层楼。",
                blanks: ["山", "海", "楼"]
            },
            {
                title: "悯农",
                author: "李绅",
                content: "锄禾日当午，汗滴禾下土。谁知盘中餐，粒粒皆辛苦。",
                blanks: ["午", "土", "辛苦"]
            },
            {
                title: "咏柳",
                author: "贺知章",
                content: "碧玉妆成一树高，万条垂下绿丝绦。不知细叶谁裁出，二月春风似剪刀。",
                blanks: ["高", "绿", "剪刀"]
            },
            {
                title: "赋得古原草送别",
                author: "白居易",
                content: "离离原上草，一岁一枯荣。野火烧不尽，春风吹又生。",
                blanks: ["草", "枯荣", "春"]
            },
            {
                title: "江雪",
                author: "柳宗元",
                content: "千山鸟飞绝，万径人踪灭。孤舟蓑笠翁，独钓寒江雪。",
                blanks: ["鸟", "人", "雪"]
            },
            {
                title: "望庐山瀑布",
                author: "李白",
                content: "日照香炉生紫烟，遥看瀑布挂前川。飞流直下三千尺，疑是银河落九天。",
                blanks: ["紫烟", "瀑布", "银河"]
            },
            {
                title: "早发白帝城",
                author: "李白",
                content: "朝辞白帝彩云间，千里江陵一日还。两岸猿声啼不住，轻舟已过万重山。",
                blanks: ["彩云", "猿", "万重"]
            },
            {
                title: "绝句",
                author: "杜甫",
                content: "两个黄鹂鸣翠柳，一行白鹭上青天。窗含西岭千秋雪，门泊东吴万里船。",
                blanks: ["黄鹂", "白鹭", "千秋"]
            },
            {
                title: "春夜喜雨",
                author: "杜甫",
                content: "好雨知时节，当春乃发生。随风潜入夜，润物细无声。",
                blanks: ["雨", "春", "夜"]
            },
            {
                title: "江南春",
                author: "杜牧",
                content: "千里莺啼绿映红，水村山郭酒旗风。南朝四百八十寺，多少楼台烟雨中。",
                blanks: ["莺", "酒旗", "烟雨"]
            },
            {
                title: "清明",
                author: "杜牧",
                content: "清明时节雨纷纷，路上行人欲断魂。借问酒家何处有，牧童遥指杏花村。",
                blanks: ["雨", "行人", "杏花"]
            },
            {
                title: "题西林壁",
                author: "苏轼",
                content: "横看成岭侧成峰，远近高低各不同。不识庐山真面目，只缘身在此山中。",
                blanks: ["岭", "峰", "山"]
            },
            {
                title: "惠崇春江晚景",
                author: "苏轼",
                content: "竹外桃花三两枝，春江水暖鸭先知。蒌蒿满地芦芽短，正是河豚欲上时。",
                blanks: ["桃花", "鸭", "河豚"]
            },
            {
                title: "小池",
                author: "杨万里",
                content: "泉眼无声惜细流，树阴照水爱晴柔。小荷才露尖尖角，早有蜻蜓立上头。",
                blanks: ["泉", "树阴", "蜻蜓"]
            },
            {
                title: "游子吟",
                author: "孟郊",
                content: "慈母手中线，游子身上衣。临行密密缝，意恐迟迟归。",
                blanks: ["线", "衣", "缝"]
            },
            {
                title: "古朗月行",
                author: "李白",
                content: "小时不识月，呼作白玉盘。又疑瑶台镜，飞在青云端。",
                blanks: ["月", "白玉盘", "青云"]
            },
            {
                title: "夜宿山寺",
                author: "李白",
                content: "危楼高百尺，手可摘星辰。不敢高声语，恐惊天上人。",
                blanks: ["百尺", "星辰", "天上"]
            },
            {
                title: "送元二使安西",
                author: "王维",
                content: "渭城朝雨浥轻尘，客舍青青柳色新。劝君更尽一杯酒，西出阳关无故人。",
                blanks: ["雨", "柳", "酒"]
            },
            {
                title: "鹿柴",
                author: "王维",
                content: "空山不见人，但闻人语响。返景入深林，复照青苔上。",
                blanks: ["人", "语", "青苔"]
            },
            {
                title: "相思",
                author: "王维",
                content: "红豆生南国，春来发几枝。愿君多采撷，此物最相思。",
                blanks: ["红豆", "春", "相思"]
            },
            {
                title: "九月九日忆山东兄弟",
                author: "王维",
                content: "独在异乡为异客，每逢佳节倍思亲。遥知兄弟登高处，遍插茱萸少一人。",
                blanks: ["异客", "思亲", "茱萸"]
            },
            {
                title: "山居秋暝",
                author: "王维",
                content: "空山新雨后，天气晚来秋。明月松间照，清泉石上流。",
                blanks: ["雨", "秋", "明月"]
            },
            {
                title: "鸟鸣涧",
                author: "王维",
                content: "人闲桂花落，夜静春山空。月出惊山鸟，时鸣春涧中。",
                blanks: ["桂花", "山鸟", "春涧"]
            },
            {
                title: "竹里馆",
                author: "王维",
                content: "独坐幽篁里，弹琴复长啸。深林人不知，明月来相照。",
                blanks: ["幽篁", "琴", "明月"]
            },
            {
                title: "送别",
                author: "王维",
                content: "山中相送罢，日暮掩柴扉。春草明年绿，王孙归不归。",
                blanks: ["送", "柴扉", "春草"]
            },
            {
                title: "杂诗",
                author: "王维",
                content: "君自故乡来，应知故乡事。来日绮窗前，寒梅著花未。",
                blanks: ["故乡", "绮窗", "寒梅"]
            },
            {
                title: "终南别业",
                author: "王维",
                content: "中岁颇好道，晚家南山陲。兴来每独往，胜事空自知。",
                blanks: ["道", "南山", "独往"]
            },
            {
                title: "观猎",
                author: "王维",
                content: "风劲角弓鸣，将军猎渭城。草枯鹰眼疾，雪尽马蹄轻。",
                blanks: ["角弓", "鹰", "马蹄"]
            },
            {
                title: "使至塞上",
                author: "王维",
                content: "单车欲问边，属国过居延。征蓬出汉塞，归雁入胡天。",
                blanks: ["边", "居延", "胡天"]
            },
            {
                title: "积雨辋川庄作",
                author: "王维",
                content: "积雨空林烟火迟，蒸藜炊黍饷东菑。漠漠水田飞白鹭，阴阴夏木啭黄鹂。",
                blanks: ["雨", "白鹭", "黄鹂"]
            },
            {
                title: "酬张少府",
                author: "王维",
                content: "晚年惟好静，万事不关心。自顾无长策，空知返旧林。",
                blanks: ["静", "关心", "旧林"]
            },
            {
                title: "过香积寺",
                author: "王维",
                content: "不知香积寺，数里入云峰。古木无人径，深山何处钟。",
                blanks: ["香积寺", "云峰", "钟"]
            },
            {
                title: "送梓州李使君",
                author: "王维",
                content: "万壑树参天，千山响杜鹃。山中一夜雨，树杪百重泉。",
                blanks: ["参天", "杜鹃", "雨"]
            },
            {
                title: "汉江临眺",
                author: "王维",
                content: "楚塞三湘接，荆门九派通。江流天地外，山色有无中。",
                blanks: ["三湘", "九派", "天地"]
            },
            {
                title: "终南山",
                author: "王维",
                content: "太乙近天都，连山接海隅。白云回望合，青霭入看无。",
                blanks: ["天都", "海隅", "白云"]
            },
            {
                title: "辋川闲居赠裴秀才迪",
                author: "王维",
                content: "寒山转苍翠，秋水日潺湲。倚杖柴门外，临风听暮蝉。",
                blanks: ["苍翠", "潺湲", "暮蝉"]
            },
            {
                title: "渭川田家",
                author: "王维",
                content: "斜光照墟落，穷巷牛羊归。野老念牧童，倚杖候荆扉。",
                blanks: ["墟落", "牛羊", "荆扉"]
            },
            {
                title: "新晴野望",
                author: "王维",
                content: "新晴原野旷，极目无氛垢。郭门临渡头，村树连溪口。",
                blanks: ["原野", "氛垢", "溪口"]
            },
            {
                title: "西施咏",
                author: "王维",
                content: "艳色天下重，西施宁久微。朝为越溪女，暮作吴宫妃。",
                blanks: ["艳色", "越溪", "吴宫"]
            },
            {
                title: "洛阳女儿行",
                author: "王维",
                content: "洛阳女儿对门居，才可容颜十五余。良人玉勒乘骢马，侍女金盘脍鲤鱼。",
                blanks: ["洛阳", "容颜", "骢马"]
            },
            {
                title: "老将行",
                author: "王维",
                content: "少年十五二十时，步行夺得胡马骑。射杀山中白额虎，肯数邺下黄须儿。",
                blanks: ["少年", "胡马", "白额虎"]
            },
            {
                title: "桃源行",
                author: "王维",
                content: "渔舟逐水爱山春，两岸桃花夹古津。坐看红树不知远，行尽青溪不见人。",
                blanks: ["渔舟", "桃花", "红树"]
            },
            {
                title: "蜀道难",
                author: "李白",
                content: "噫吁嚱，危乎高哉！蜀道之难，难于上青天。使人听此凋朱颜。",
                blanks: ["危", "蜀道", "朱颜"]
            },
            {
                title: "将进酒",
                author: "李白",
                content: "君不见黄河之水天上来，奔流到海不复回。君不见高堂明镜悲白发，朝如青丝暮成雪。",
                blanks: ["黄河", "海", "白发"]
            },
            {
                title: "行路难",
                author: "李白",
                content: "金樽清酒斗十千，玉盘珍羞直万钱。停杯投箸不能食，拔剑四顾心茫然。",
                blanks: ["金樽", "玉盘", "剑"]
            },
            {
                title: "梦游天姥吟留别",
                author: "李白",
                content: "海客谈瀛洲，烟涛微茫信难求。越人语天姥，云霓明灭或可睹。",
                blanks: ["瀛洲", "烟涛", "天姥"]
            },
            {
                title: "宣州谢朓楼饯别校书叔云",
                author: "李白",
                content: "弃我去者，昨日之日不可留。乱我心者，今日之日多烦忧。",
                blanks: ["昨日", "今日", "烦忧"]
            },
            {
                title: "月下独酌",
                author: "李白",
                content: "花间一壶酒，独酌无相亲。举杯邀明月，对影成三人。",
                blanks: ["酒", "明月", "三人"]
            },
            {
                title: "关山月",
                author: "李白",
                content: "明月出天山，苍茫云海间。长风几万里，吹度玉门关。",
                blanks: ["明月", "天山", "玉门"]
            },
            {
                title: "子夜吴歌",
                author: "李白",
                content: "长安一片月，万户捣衣声。秋风吹不尽，总是玉关情。",
                blanks: ["长安", "捣衣", "玉关"]
            },
            {
                title: "长干行",
                author: "李白",
                content: "妾发初覆额，折花门前剧。郎骑竹马来，绕床弄青梅。",
                blanks: ["发", "竹马", "青梅"]
            },
            {
                title: "清平调",
                author: "李白",
                content: "云想衣裳花想容，春风拂槛露华浓。若非群玉山头见，会向瑶台月下逢。",
                blanks: ["云", "春风", "瑶台"]
            },
            {
                title: "秋浦歌",
                author: "李白",
                content: "白发三千丈，缘愁似个长。不知明镜里，何处得秋霜。",
                blanks: ["白发", "愁", "秋霜"]
            },
            {
                title: "赠汪伦",
                author: "李白",
                content: "李白乘舟将欲行，忽闻岸上踏歌声。桃花潭水深千尺，不及汪伦送我情。",
                blanks: ["舟", "踏歌", "桃花潭"]
            },
            {
                title: "望天门山",
                author: "李白",
                content: "天门中断楚江开，碧水东流至此回。两岸青山相对出，孤帆一片日边来。",
                blanks: ["天门", "楚江", "孤帆"]
            },
            {
                title: "独坐敬亭山",
                author: "李白",
                content: "众鸟高飞尽，孤云独去闲。相看两不厌，只有敬亭山。",
                blanks: ["鸟", "云", "敬亭山"]
            },
            {
                title: "夜思",
                author: "李白",
                content: "床前明月光，疑是地上霜。举头望明月，低头思故乡。",
                blanks: ["明月", "霜", "故乡"]
            },
            {
                title: "怨情",
                author: "李白",
                content: "美人卷珠帘，深坐蹙蛾眉。但见泪痕湿，不知心恨谁。",
                blanks: ["珠帘", "蛾眉", "泪痕"]
            },
            {
                title: "玉阶怨",
                author: "李白",
                content: "玉阶生白露，夜久侵罗袜。却下水晶帘，玲珑望秋月。",
                blanks: ["白露", "罗袜", "秋月"]
            },
            {
                title: "春思",
                author: "李白",
                content: "燕草如碧丝，秦桑低绿枝。当君怀归日，是妾断肠时。",
                blanks: ["燕草", "秦桑", "断肠"]
            },
            {
                title: "秋思",
                author: "李白",
                content: "春阳如昨日，碧树鸣黄鹂。芜然蕙草暮，飒尔凉风吹。",
                blanks: ["春阳", "黄鹂", "凉风"]
            },
            {
                title: "春怨",
                author: "李白",
                content: "白马金羁辽海东，罗帷绣被卧春风。落月低轩窥烛尽，飞花入户笑床空。",
                blanks: ["白马", "春风", "飞花"]
            },
            {
                title: "秋浦歌",
                author: "李白",
                content: "炉火照天地，红星乱紫烟。赧郎明月夜，歌曲动寒川。",
                blanks: ["炉火", "红星", "寒川"]
            },
            {
                title: "清溪行",
                author: "李白",
                content: "清溪清我心，水色异诸水。借问新安江，见底何如此。",
                blanks: ["清溪", "水色", "新安江"]
            },
            {
                title: "宣城见杜鹃花",
                author: "李白",
                content: "蜀国曾闻子规鸟，宣城还见杜鹃花。一叫一回肠一断，三春三月忆三巴。",
                blanks: ["子规", "杜鹃", "三巴"]
            },
            {
                title: "白鹭鸶",
                author: "李白",
                content: "白鹭下秋水，孤飞如坠霜。心闲且未去，独立沙洲傍。",
                blanks: ["白鹭", "秋水", "沙洲"]
            },
            {
                title: "观放白鹰",
                author: "李白",
                content: "八月边风高，胡鹰白锦毛。孤飞一片雪，百里见秋毫。",
                blanks: ["边风", "白锦", "秋毫"]
            },
            {
                title: "观猎",
                author: "李白",
                content: "太守耀清威，乘闲弄晚晖。江沙横猎骑，山火绕行围。",
                blanks: ["清威", "晚晖", "山火"]
            },
            {
                title: "军行",
                author: "李白",
                content: "骝马新跨白玉鞍，战罢沙场月色寒。城头铁鼓声犹震，匣里金刀血未干。",
                blanks: ["骝马", "沙场", "金刀"]
            },
            {
                title: "从军行",
                author: "李白",
                content: "百战沙场碎铁衣，城南已合数重围。突营射杀呼延将，独领残兵千骑归。",
                blanks: ["铁衣", "重围", "残兵"]
            },
            {
                title: "塞下曲",
                author: "李白",
                content: "五月天山雪，无花只有寒。笛中闻折柳，春色未曾看。",
                blanks: ["天山", "雪", "折柳"]
            },
            {
                title: "玉门关",
                author: "李白",
                content: "青海长云暗雪山，孤城遥望玉门关。黄沙百战穿金甲，不破楼兰终不还。",
                blanks: ["青海", "玉门", "楼兰"]
            },
            {
                title: "春望",
                author: "杜甫",
                content: "国破山河在，城春草木深。感时花溅泪，恨别鸟惊心。",
                blanks: ["山河", "草木", "花"]
            },
            {
                title: "茅屋为秋风所破歌",
                author: "杜甫",
                content: "八月秋高风怒号，卷我屋上三重茅。茅飞渡江洒江郊，高者挂罥长林梢。",
                blanks: ["秋高", "茅", "江郊"]
            },
            {
                title: "闻官军收河南河北",
                author: "杜甫",
                content: "剑外忽传收蓟北，初闻涕泪满衣裳。却看妻子愁何在，漫卷诗书喜欲狂。",
                blanks: ["剑外", "涕泪", "诗书"]
            },
            {
                title: "登高",
                author: "杜甫",
                content: "风急天高猿啸哀，渚清沙白鸟飞回。无边落木萧萧下，不尽长江滚滚来。",
                blanks: ["猿", "鸟", "长江"]
            },
            {
                title: "旅夜书怀",
                author: "杜甫",
                content: "细草微风岸，危樯独夜舟。星垂平野阔，月涌大江流。",
                blanks: ["细草", "危樯", "大江"]
            },
            {
                title: "登岳阳楼",
                author: "杜甫",
                content: "昔闻洞庭水，今上岳阳楼。吴楚东南坼，乾坤日夜浮。",
                blanks: ["洞庭", "岳阳楼", "乾坤"]
            },
            {
                title: "江南逢李龟年",
                author: "杜甫",
                content: "岐王宅里寻常见，崔九堂前几度闻。正是江南好风景，落花时节又逢君。",
                blanks: ["岐王", "崔九", "落花"]
            },
            {
                title: "八阵图",
                author: "杜甫",
                content: "功盖三分国，名成八阵图。江流石不转，遗恨失吞吴。",
                blanks: ["三分", "八阵", "吞吴"]
            },
            {
                title: "绝句",
                author: "杜甫",
                content: "迟日江山丽，春风花草香。泥融飞燕子，沙暖睡鸳鸯。",
                blanks: ["江山", "春风", "燕子"]
            },
            {
                title: "江畔独步寻花",
                author: "杜甫",
                content: "黄四娘家花满蹊，千朵万朵压枝低。留连戏蝶时时舞，自在娇莺恰恰啼。",
                blanks: ["花", "蝶", "莺"]
            },
            {
                title: "水槛遣心",
                author: "杜甫",
                content: "去郭轩楹敞，无村眺望赊。澄江平少岸，幽树晚多花。",
                blanks: ["轩楹", "澄江", "幽树"]
            },
            {
                title: "曲江",
                author: "杜甫",
                content: "一片花飞减却春，风飘万点正愁人。且看欲尽花经眼，莫厌伤多酒入唇。",
                blanks: ["花", "风", "酒"]
            },
            {
                title: "九日蓝田崔氏庄",
                author: "杜甫",
                content: "老去悲秋强自宽，兴来今日尽君欢。羞将短发还吹帽，笑倩旁人为正冠。",
                blanks: ["悲秋", "短发", "正冠"]
            },
            {
                title: "月夜忆舍弟",
                author: "杜甫",
                content: "戍鼓断人行，边秋一雁声。露从今夜白，月是故乡明。",
                blanks: ["戍鼓", "雁", "月"]
            },
            {
                title: "天末怀李白",
                author: "杜甫",
                content: "凉风起天末，君子意如何。鸿雁几时到，江湖秋水多。",
                blanks: ["凉风", "鸿雁", "秋水"]
            },
            {
                title: "奉济驿重送严公四韵",
                author: "杜甫",
                content: "远送从此别，青山空复情。几时杯重把，昨夜月同行。",
                blanks: ["远送", "青山", "月"]
            },
            {
                title: "别房太尉墓",
                author: "杜甫",
                content: "他乡复行役，驻马别孤坟。近泪无干土，低空有断云。",
                blanks: ["行役", "孤坟", "断云"]
            }
        ];

        let currentPoemIndex = 0;
        let score = 0;
        let currentQuestion = 1;

        // 初始化游戏
        function initGame() {
            currentPoemIndex = Math.floor(Math.random() * poems.length);
            displayPoem();
        }

        // 显示古诗
        function displayPoem() {
            const poem = poems[currentPoemIndex];
            document.getElementById('poemTitle').textContent = poem.title;
            document.getElementById('poemAuthor').textContent = `作者：${poem.author}`;

            let content = poem.content;
            let blankIndex = 0;

            // 为每个填空创建输入框
            poem.blanks.forEach(blank => {
                const input =
                    `<input type="text" class="blank" id="blank${blankIndex}" placeholder="填空" maxlength="10">`;
                content = content.replace(blank, input);
                blankIndex++;
            });

            document.getElementById('poemLines').innerHTML = content;

            // 隐藏结果区域
            document.getElementById('resultArea').style.display = 'none';
            document.getElementById('fullPoemArea').style.display = 'none';
            document.getElementById('nextBtn').style.display = 'none';
        }

        // 检查答案
        function checkAnswer() {
            const poem = poems[currentPoemIndex];
            const resultArea = document.getElementById('resultArea');
            const fullPoemArea = document.getElementById('fullPoemArea');
            const nextBtn = document.getElementById('nextBtn');

            let allCorrect = true;
            let userAnswers = [];

            // 获取用户答案
            for (let i = 0; i < poem.blanks.length; i++) {
                const userAnswer = document.getElementById(`blank${i}`).value.trim();
                userAnswers.push(userAnswer);

                if (userAnswer.toLowerCase() !== poem.blanks[i].toLowerCase()) {
                    allCorrect = false;
                }
            }

            // 显示结果
            if (allCorrect) {
                score += 10;
                resultArea.innerHTML = `
                    <div class="result correct">
                        <h3>🎉 恭喜你答对了！</h3>
                        <p>你的答案：${userAnswers.join('、')}</p>
                        <p class="score">+10分！当前总分：${score}</p>
                    </div>
                `;
            } else {
                resultArea.innerHTML = `
                    <div class="result incorrect">
                        <h3>❌ 答案不正确</h3>
                        <p>你的答案：${userAnswers.join('、')}</p>
                        <p>正确答案：${poem.blanks.join('、')}</p>
                    </div>
                `;
            }

            // 显示完整诗句
            fullPoemArea.innerHTML = `
                <div class="full-poem">
                    <h4>📖 完整诗句：</h4>
                    <p><strong>${poem.title}</strong> - ${poem.author}</p>
                    <p>${poem.content}</p>
                </div>
            `;

            resultArea.style.display = 'block';
            fullPoemArea.style.display = 'block';
            nextBtn.style.display = 'inline-block';

            // 更新分数显示
            document.getElementById('score').textContent = score;
        }

        // 下一题
        function nextQuestion() {
            currentQuestion++;
            document.getElementById('currentQuestion').textContent = currentQuestion;

            // 随机选择下一首诗
            let nextIndex;
            do {
                nextIndex = Math.floor(Math.random() * poems.length);
            } while (nextIndex === currentPoemIndex && poems.length > 1);

            currentPoemIndex = nextIndex;
            displayPoem();
        }

        // 回车键提交答案
        document.addEventListener('keypress', function (event) {
            if (event.key === 'Enter') {
                checkAnswer();
            }
        });

        // 页面加载完成后初始化游戏
        window.onload = function () {
            initGame();
        };
    </script>
</body>

</html>